package com.jlcloud.core.tenant.dynamic;

import com.baomidou.dynamic.datasource.processor.DsProcessor;
import org.aopalliance.intercept.MethodInvocation;
import com.jlcloud.core.tenant.TenantUtil;

/**
 * 租户动态数据源解析器
 *
 * @author By: JlCloud <br>
 * @Package: com.jlcloud <br>
 * @CreateTime: 2024-12-03 21:45 <br>
 * @Copyright: 2021 www.jilianjituan.com Inc. All rights reserved. <br>
 * @Caution 注意：本内容仅限于冀联人力集团内部传阅，禁止外泄以及用于其他的商业目的 <br>
 */
public class DsTenantIdProcessor extends DsProcessor {

	public static final String TENANT_ID_KEY = "#token.tenantId";

	@Override
	public boolean matches(String key) {
		return key.equals(TENANT_ID_KEY);
	}

	@Override
	public String doDetermineDatasource(MethodInvocation invocation, String key) {
		return TenantUtil.getTenantId();
	}

}
